/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.gruposp2p.dnie.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
 *
 * @author jj
 */
@XmlType
@XmlRootElement(name = "DNIeTag")
@XmlAccessorType(XmlAccessType.NONE)
@Entity
@Table(name = "DNIETAG", catalog = "DNIE")
@NamedQueries({
    @NamedQuery(name = "DNIeTag.findAll", query = "SELECT d FROM DNIeTag d"),
    @NamedQuery(name = "DNIeTag.findById", query = "SELECT d FROM DNIeTag d WHERE d.id = :id"),
    @NamedQuery(name = "DNIeTag.findByName", query = "SELECT d FROM DNIeTag d WHERE d.name = :name"),
    @NamedQuery(name = "DNIeTag.findByDescription", query = "SELECT d FROM DNIeTag d WHERE d.description = :description")})
public class DNIeTag implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    @XmlElement
    private Integer id;
    @Basic(optional = false)
    @Column(name = "NAME", nullable = false, length = 50)
    @XmlElement
    private String name;
    @Column(name = "DESCRIPTION", length = 500)
    @XmlElement
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "dnieTagId")
    private Collection<DocumentTag> documentTagCollection;

    public DNIeTag() {
    }

    public DNIeTag(Integer id) {
        this.id = id;
    }

    public DNIeTag(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Collection<DocumentTag> getDocumentTagCollection() {
        return documentTagCollection;
    }

    public void setDocumentTagCollection(Collection<DocumentTag> documentTagCollection) {
        this.documentTagCollection = documentTagCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DNIeTag)) {
            return false;
        }
        DNIeTag other = (DNIeTag) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.gruposp2p.dnie.model.DNIeTag[id=" + id + "]";
    }

}
